import React, {Component} from 'react'
import StudentManagement from './management/student-management'
import TutorManagement from './management/tutor-management'
import MembersManagement from './management/members-management'
import RolesManagement from './management/roles/roles-management-body-page'
import OrganizationLink from './management/organization-link-page'
import {getLangFromLocalStorage} from '../constant/lang-util'
import locales from '../locales'
import { LocaleProvider } from 'antd'
import { IntlProvider } from 'react-intl'
import { connect } from 'react-redux'
import TwsLayout from './tws-layout'
import {
    HashRouter as Router,
    Route
} from 'react-router-dom'
import UsersImportBody from './management/users/users-import-body'
import BasicQuizzesManagementBody from './management/basicQuiz/basic-quizzes-management-body'

class App extends Component {
  render () {
    const lang = this.props.lang || getLangFromLocalStorage()
    const langData = locales[lang]
    return (
      <IntlProvider locale={langData.intlLocale} messages={langData.intlMessage}>
        <LocaleProvider locale={langData.locale}>
          <Router>
            <TwsLayout>
              <Route exact path='/' component={StudentManagement} />
              <Route path='/programs' component={StudentManagement} />
              <Route path='/tutors' component={TutorManagement} />
              <Route path='/members' component={MembersManagement} />
              <Route path='/roles' component={RolesManagement} />
              <Route path='/organizations/link' component={OrganizationLink} />
              <Route path='/users/imports' component={UsersImportBody} />
              <Route path='/basic-quizzes' component={BasicQuizzesManagementBody} />
            </TwsLayout>
          </Router>
        </LocaleProvider>
      </IntlProvider>
    )
  }
}

const mapStateToProps = ({lang}) => ({lang})

export default connect(mapStateToProps)(App)
